/*
 * Created on Wed Feb 21 2024
 *
 * This file is a part of Skytable
 * Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source
 * NoSQL database written by Sayan Nandan ("the Author") with the
 * vision to provide flexibility in data modelling without compromising
 * on performance, queryability or scalability.
 *
 * Copyright (c) 2024, Sayan Nandan <nandansayan@outlook.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 *
*/

#[derive(Debug, PartialEq, Clone, Copy)]
pub struct CreateUserTxn<'a> {
    username: &'a str,
    password_hash: &'a [u8],
}

impl<'a> CreateUserTxn<'a> {
    pub fn new(username: &'a str, password_hash: &'a [u8]) -> Self {
        Self {
            username,
            password_hash,
        }
    }
    pub fn username(&self) -> &str {
        self.username
    }
    pub fn password_hash(&self) -> &[u8] {
        self.password_hash
    }
}

#[derive(Debug, PartialEq, Clone, Copy)]
pub struct AlterUserTxn<'a> {
    username: &'a str,
    password_hash: &'a [u8],
}

impl<'a> AlterUserTxn<'a> {
    pub fn new(username: &'a str, password_hash: &'a [u8]) -> Self {
        Self {
            username,
            password_hash,
        }
    }
    pub fn username(&self) -> &str {
        self.username
    }
    pub fn password_hash(&self) -> &[u8] {
        self.password_hash
    }
}

#[derive(Debug, PartialEq, Clone, Copy)]
pub struct DropUserTxn<'a> {
    username: &'a str,
}

impl<'a> DropUserTxn<'a> {
    pub fn new(username: &'a str) -> Self {
        Self { username }
    }
    pub fn username(&self) -> &str {
        self.username
    }
}

impl_gns_event!(CreateUserTxn<'_> = CreateUser, AlterUserTxn<'_> = AlterUser, DropUserTxn<'_> = DropUser);
